package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.PostDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.Post;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface PostMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    BasicColumn[] selectList = BasicColumn.columnList(postId, postCode, postName, postSort, status, createBy, createTime, updateBy, updateTime, remark);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<Post> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("PostResult")
    Optional<Post> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="PostResult", value = {
        @Result(column="post_id", property="postId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="post_code", property="postCode", jdbcType=JdbcType.VARCHAR),
        @Result(column="post_name", property="postName", jdbcType=JdbcType.VARCHAR),
        @Result(column="post_sort", property="postSort", jdbcType=JdbcType.INTEGER),
        @Result(column="status", property="status", jdbcType=JdbcType.CHAR),
        @Result(column="create_by", property="createBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="update_by", property="updateBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR)
    })
    List<Post> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, post, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, post, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.614+08:00", comments="Source Table: sys_post")
    default int deleteByPrimaryKey(Long postId_) {
        return delete(c -> 
            c.where(postId, isEqualTo(postId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default int insert(Post record) {
        return MyBatis3Utils.insert(this::insert, record, post, c ->
            c.map(postId).toProperty("postId")
            .map(postCode).toProperty("postCode")
            .map(postName).toProperty("postName")
            .map(postSort).toProperty("postSort")
            .map(status).toProperty("status")
            .map(createBy).toProperty("createBy")
            .map(createTime).toProperty("createTime")
            .map(updateBy).toProperty("updateBy")
            .map(updateTime).toProperty("updateTime")
            .map(remark).toProperty("remark")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default int insertSelective(Post record) {
        return MyBatis3Utils.insert(this::insert, record, post, c ->
            c.map(postId).toPropertyWhenPresent("postId", record::getPostId)
            .map(postCode).toPropertyWhenPresent("postCode", record::getPostCode)
            .map(postName).toPropertyWhenPresent("postName", record::getPostName)
            .map(postSort).toPropertyWhenPresent("postSort", record::getPostSort)
            .map(status).toPropertyWhenPresent("status", record::getStatus)
            .map(createBy).toPropertyWhenPresent("createBy", record::getCreateBy)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(updateBy).toPropertyWhenPresent("updateBy", record::getUpdateBy)
            .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
            .map(remark).toPropertyWhenPresent("remark", record::getRemark)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default Optional<Post> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, post, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default List<Post> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, post, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default List<Post> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, post, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default Optional<Post> selectByPrimaryKey(Long postId_) {
        return selectOne(c ->
            c.where(postId, isEqualTo(postId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, post, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    static UpdateDSL<UpdateModel> updateAllColumns(Post record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(postId).equalTo(record::getPostId)
                .set(postCode).equalTo(record::getPostCode)
                .set(postName).equalTo(record::getPostName)
                .set(postSort).equalTo(record::getPostSort)
                .set(status).equalTo(record::getStatus)
                .set(createBy).equalTo(record::getCreateBy)
                .set(createTime).equalTo(record::getCreateTime)
                .set(updateBy).equalTo(record::getUpdateBy)
                .set(updateTime).equalTo(record::getUpdateTime)
                .set(remark).equalTo(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Post record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(postId).equalToWhenPresent(record::getPostId)
                .set(postCode).equalToWhenPresent(record::getPostCode)
                .set(postName).equalToWhenPresent(record::getPostName)
                .set(postSort).equalToWhenPresent(record::getPostSort)
                .set(status).equalToWhenPresent(record::getStatus)
                .set(createBy).equalToWhenPresent(record::getCreateBy)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(updateBy).equalToWhenPresent(record::getUpdateBy)
                .set(updateTime).equalToWhenPresent(record::getUpdateTime)
                .set(remark).equalToWhenPresent(record::getRemark);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default int updateByPrimaryKey(Post record) {
        return update(c ->
            c.set(postCode).equalTo(record::getPostCode)
            .set(postName).equalTo(record::getPostName)
            .set(postSort).equalTo(record::getPostSort)
            .set(status).equalTo(record::getStatus)
            .set(createBy).equalTo(record::getCreateBy)
            .set(createTime).equalTo(record::getCreateTime)
            .set(updateBy).equalTo(record::getUpdateBy)
            .set(updateTime).equalTo(record::getUpdateTime)
            .set(remark).equalTo(record::getRemark)
            .where(postId, isEqualTo(record::getPostId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.615+08:00", comments="Source Table: sys_post")
    default int updateByPrimaryKeySelective(Post record) {
        return update(c ->
            c.set(postCode).equalToWhenPresent(record::getPostCode)
            .set(postName).equalToWhenPresent(record::getPostName)
            .set(postSort).equalToWhenPresent(record::getPostSort)
            .set(status).equalToWhenPresent(record::getStatus)
            .set(createBy).equalToWhenPresent(record::getCreateBy)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(updateBy).equalToWhenPresent(record::getUpdateBy)
            .set(updateTime).equalToWhenPresent(record::getUpdateTime)
            .set(remark).equalToWhenPresent(record::getRemark)
            .where(postId, isEqualTo(record::getPostId))
        );
    }
}